package cn.demarcia.coco.uihelper;

import android.content.Context;
import android.content.Intent;
import android.widget.ImageView;

import cn.demarcia.coco.R;
import cn.demarcia.coco.ui.activity.CalendarActivity;
import cn.demarcia.coco.ui.activity.JokeActivity;
import cn.demarcia.coco.ui.activity.MainActivity;
import cn.demarcia.coco.ui.activity.NewsActivity;
import cn.demarcia.coco.ui.activity.WeatherActivity;
import cn.demarcia.coco.ui.activity.WebViewActivity;
import info.jimao.newsdk.models.NewsInfoModel;

/**
 * Created by 智尧
 * on 2016/7/18.
 */
public class UIHelper {
    public static final int LIST_VIEW_DATA_LOADING = 1;
    public static final int LIST_VIEW_DATA_REFRESH = 2;
    public static final int LIST_VIEW_DATA_MORE = 3;
    public final static int SCANNING_REQUEST_CODE = 1;


    public static void showNews(Context context) {
        if (!(context instanceof NewsActivity)) {
            Intent intent = new Intent(context, NewsActivity.class);
            context.startActivity(intent);
        }
    }

    public static void showWebViewActivity(Context context, NewsInfoModel model) {
        if (!(context instanceof WebViewActivity)) {
            Intent intent = new Intent(context, WebViewActivity.class);
            intent.putExtra("model", model);
            context.startActivity(intent);
        }
    }

    public static void showCalendar(Context context) {
        if (!(context instanceof CalendarActivity)) {
            Intent intent = new Intent(context, CalendarActivity.class);
            context.startActivity(intent);
        }
    }

    public static void showMainActivity(Context context) {
        if (!(context instanceof MainActivity)) {
            Intent intent = new Intent(context, MainActivity.class);
            context.startActivity(intent);
        }
    }

    public static void showWeather(Context context) {
        if (!(context instanceof WeatherActivity)) {
            Intent intent = new Intent(context, WeatherActivity.class);
            context.startActivity(intent);
        }
    }

    public static void showWeatherIcon(ImageView ivWeather, String weatherInfo) {
        switch (weatherInfo) {
            case "晴":
                ivWeather.setImageResource(R.drawable.day0);
                break;
            case "多云":
                ivWeather.setImageResource(R.drawable.day1);
                break;
            case "阴":
                ivWeather.setImageResource(R.drawable.day2);
                break;
            case "阵雨":
                ivWeather.setImageResource(R.drawable.day3);
                break;
            case "雷阵雨":
                ivWeather.setImageResource(R.drawable.day4);
                break;
            case "雨夹雪":
                ivWeather.setImageResource(R.drawable.day6);
                break;
            case "小雨":
                ivWeather.setImageResource(R.drawable.day8);
                break;
            case "中雨":
                ivWeather.setImageResource(R.drawable.day9);
                break;
            case "大雨":
            case "暴雨":
            case "大暴雨":
            case "特大暴雨":
                ivWeather.setImageResource(R.drawable.day11);
                break;
            case "阵雪":
                ivWeather.setImageResource(R.drawable.day13);
                break;
            case "小雪":
                ivWeather.setImageResource(R.drawable.day14);
                break;
            case "中雪":
                ivWeather.setImageResource(R.drawable.day15);
                break;
            case "大雪":
            case "暴雪":
                ivWeather.setImageResource(R.drawable.day17);
                break;
            case "雾":
                ivWeather.setImageResource(R.drawable.day18);
                break;
            case "扬沙":
            case "浮沉":
            case "沙尘暴":
                ivWeather.setImageResource(R.drawable.day20);
                break;
            default:
                ivWeather.setImageResource(R.drawable.weather_na);
                break;
        }
    }

    public static void showJoke(Context context) {
        if (!(context instanceof JokeActivity)) {
            Intent intent = new Intent(context, JokeActivity.class);
            context.startActivity(intent);
        }
    }
}
